package com.sairobo.admin.modules.srblive.manager.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.sairobo.base.common.constant.QueryConts;
import com.sairobo.base.common.entity.Page;
import com.sairobo.base.common.entity.Query;
import com.sairobo.admin.modules.srblive.dao.SrbliveFileMapper;
import com.sairobo.admin.modules.srblive.entity.SrbliveFileEntity;
import com.sairobo.admin.modules.srblive.manager.SrbliveFileManager;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

/**
 * 文件目录
 *
 * @author admin
 * @email sairobo
 * @url www.sairobo.com
 * @date 2018年1月09日 上午10:41:05
 */
@Component("srbliveFileManager")
public class SrbliveFileManagerImpl extends ServiceImpl<SrbliveFileMapper, SrbliveFileEntity> implements SrbliveFileManager {


	@Override
	public List<SrbliveFileEntity> listSrbliveFile(Page<SrbliveFileEntity> page, Query search) {
		EntityWrapper<SrbliveFileEntity> ew = new EntityWrapper<SrbliveFileEntity>();

		//搜索条件
        Map map = (HashMap)search.get(QueryConts.SEARCH_KEYWORD);
        ew.like("file_Name",(String) map.get("key"));

        String classRoomId  =  (String)map.get("classRoomId");
        if(StringUtils.isNotEmpty(classRoomId)){
            ew.eq("classroom_id",classRoomId);
        }
		return baseMapper.selectPage(page, ew);
	}

	@Override
	public int saveSrbliveFile(SrbliveFileEntity srbliveFile) {
		return baseMapper.insert(srbliveFile);
	}

	@Override
	public SrbliveFileEntity getSrbliveFileById(Long id) {
		SrbliveFileEntity srbliveFile = baseMapper.selectById(id);
		return srbliveFile;
	}

	@Override
	public int updateSrbliveFile(SrbliveFileEntity srbliveFile) {
		return baseMapper.updateById(srbliveFile);
	}

	@Override
	public int batchRemove(Long[] id) {
		int count = baseMapper.batchRemove(id);
		return count;
	}
	
}
